home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWTStack.z / RWTStack
Encoding:
Text File  |  1998-10-30  |  4.2 KB  |  133 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTSSSSttttaaaacccckkkk((((3333CCCC++++++++))))                                                  RRRRWWWWTTTTSSSSttttaaaacccckkkk((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTStack<T,C> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/tstack.h>
  13.  
  14.  
  15.  
  16.               RWTStack<T, C> stack;
  17.  
  18.  
  19.  
  20.  
  21. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  22.      This class maintains a stack of values.  Not only can the type of object
  23.      inserted onto the stack be parameterized, but also the implementation of
  24.      the stack. Parameter TTTT represents the type of object in the stack, either
  25.      a class or built in type.  The class TTTT must have:
  26.           well-defined copy semantics (TTTT::::::::TTTT((((ccccoooonnnnsssstttt TTTT&&&&)))) or equiv.);
  27.  
  28.           well-defined assignment semantics (TTTT::::::::ooooppppeeeerrrraaaattttoooorrrr====((((ccccoooonnnnsssstttt TTTT&&&&)))) or
  29.           equiv.);
  30.  
  31.           any other semantics required by class C.
  32.  
  33.  
  34. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  35.      Parameter C represents the class used for implementation.  Useful choices
  36.      are RRRRWWWWTTTTVVVVaaaallllOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr<<<<TTTT>>>> or RRRRWWWWTTTTVVVVaaaallllDDDDlllliiiisssstttt<<<<TTTT>>>>.  Class RRRRWWWWTTTTVVVVaaaallllSSSSlllliiiisssstttt<<<<TTTT>>>> can
  37.      also be used, but note that singly-linked lists are less efficient at
  38.      removing the last item of a list (function ppppoooopppp(((())))), because of the
  39.      necessity of searching the list for the next-to-the-last item.  None
  40.  
  41. EEEExxxxaaaammmmpppplllleeee
  42.      In this example a stack of iiiinnnntttts, implemented as an ordered vector, is
  43.      exercised.
  44.  
  45.               #include <rw/tstack.h>
  46.           #include <rw/tvordvec.h>
  47.           #include <rw/rstream.h>
  48.           main() {
  49.             RWTStack<int, RWTValOrderedVector<int> > stack;
  50.             stack.push(1);
  51.             stack.push(5);
  52.             stack.push(6);
  53.             while (!stack.isEmpty())
  54.               cout << stack.pop() << endl;
  55.             return 0;
  56.           }
  57.  
  58.  
  59.      Program output:
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTSSSSttttaaaacccckkkk((((3333CCCC++++++++))))                                                  RRRRWWWWTTTTSSSSttttaaaacccckkkk((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               6
  75.           5
  76.  
  77. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  78.      1
  79.  
  80.  
  81.  
  82.               void
  83.           cccclllleeeeaaaarrrr();
  84.  
  85.  
  86.      Removes all items from the stack.
  87.  
  88.               size_t
  89.           eeeennnnttttrrrriiiieeeessss() const;
  90.  
  91.  
  92.      Returns the number of items currently on the stack.
  93.  
  94.               RWBoolean
  95.           iiiissssEEEEmmmmppppttttyyyy() const;
  96.  
  97.  
  98.      Returns TTTTRRRRUUUUEEEE if there are currently no items on the stack, FFFFAAAALLLLSSSSEEEE
  99.      otherwise.
  100.  
  101.               void
  102.           ppppuuuusssshhhh(T a);
  103.  
  104.  
  105.      Push the item aaaa onto the top of the stack.
  106.  
  107.               T
  108.           ppppoooopppp();
  109.  
  110.  
  111.      Pop (remove and return) the item at the top of the stack.  If there are
  112.      no items on the stack then an exception of type TTTTOOOOOOOOLLLL____IIIINNNNDDDDEEEEXXXX will occur.
  113.  
  114.               T
  115.           ttttoooopppp() const;
  116.  
  117.  
  118.      Returns (but does not remove) the item at the top of the stack.
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.